package com.example.rankscore;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

public class Menu extends Activity {
	ImageButton btn_start;
	ImageButton btn_history;
	ImageButton btn_option;

	private void CallNewActivity(int x) {
		Intent Intent_start = new Intent(Menu.this, Start.class);
		Intent Intent_history = new Intent(Menu.this, History.class);
		Intent Intent_option = new Intent(Menu.this, Option.class);
		if (x == 1)
			startActivity(Intent_start);
		else if (x == 2)
			startActivity(Intent_history);
		else if (x == 3)
			startActivity(Intent_option);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_menu);

		// Khi nhan start
		btn_start = (ImageButton) findViewById(R.id.btn_start);
		btn_start.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0) {
				int a = 1;
				CallNewActivity(a);
			}
		});

		// Khi nhan history
		btn_history = (ImageButton) findViewById(R.id.btn_history);
		btn_history.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0) {
				int a = 2;
				CallNewActivity(a);
			}
		});

		// Khi nhan option
		btn_option = (ImageButton) findViewById(R.id.btn_option);
		btn_option.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0) {
				int a = 3;
				CallNewActivity(a);
			}
		});
	}

	public boolean onCreateOptionsMenu(android.view.Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
